<extend name="Home@Include:Layout"/>
<block name="title">阳光灿烂课程报名支付页面</block>
<block name="style">
<style>
.weui_cells {font-size:14px;}
.popup-bottom .weui-popup-modal {height:80%;overflow-y:scroll;}
</style>
</block>

<block name="main">
<div class="weui_tab">
  <div class="weui_navbar">
 	 <div class="toolbar">
          <div class="toolbar-inner">
          	 <a href="javascript:history.go(-1);" class="picker-button close-popup">关闭</a>
            <h1 class="title">报名支付信息</h1>
          </div>
    </div>
  </div>
  <div class="weui_tab_bd">
    <div class="weui_tab_bd_item weui_tab_bd_item_active">
    	<div class="weui_cells weui_cells_form">
    	  <div class="weui_cell">
		    <div class="weui_cell_hd"><label class="weui_label">学期信息</label></div>
		    <div class="weui_cell_bd weui_cell_primary">{$info['term']['title']}</div>
		  </div>
		  <div class="weui_cell">
		    <div class="weui_cell_hd"><label class="weui_label">学生姓名</label></div>
		    <div class="weui_cell_bd weui_cell_primary">{$info.stuname}</div>
		  </div>
		  <div class="weui_cell">
		    <div class="weui_cell_hd"><label class="weui_label">出生日期</label></div>
		    <div class="weui_cell_bd weui_cell_primary">{$info.birthday}</div>
		  </div>
		  <div class="weui_cell">
		    <div class="weui_cell_hd"><label class="weui_label">手机号码</label></div>
		    <div class="weui_cell_bd weui_cell_primary">{$info.tel}</div>
		  </div>
		  <div class="weui_cell">
		    <div class="weui_cell_hd"><label for="" class="weui_label">家长姓名</label></div>
		    <div class="weui_cell_bd weui_cell_primary">{$info.jzxm}</div>
		  </div>
		  <div class="weui_cell">
		    <div class="weui_cell_hd"><label class="weui_label">校区</label></div>
		    <div class="weui_cell_bd weui_cell_primary">
		    	{$info.xiaoqu.title}
		    </div>
		  </div>
		  <div class="weui_cell banjiDom">
		    <div class="weui_cell_hd"><label class="weui_label">课程</label></div>
		    <div class="weui_cell_bd weui_cell_primary">{$info.kecheng.title}</div>
		  </div>
		  
		  <div class="weui_cell banjiDom">
		   	<div class="weui_cell_hd"><label class="weui_label">班级</label></div>
		    <div class="weui_cell_bd weui_cell_primary">
		    	{$info.lesson.lessoncode}
		    </div>
		  </div>
		  <div class="weui_cell banjiDom">
		    <div class="weui_cell_hd"><label class="weui_label">学期</label></div>
		    <div class="weui_cell_bd weui_cell_primary">
		    	{$info.detail.info}
		    </div>
		  </div>
		  <div class="weui_cell">
		    <div class="weui_cell_hd"><label class="weui_label">费用</label></div>
		    <div class="weui_cell_bd weui_cell_primary">{$info.total}</div>
		  </div>
		   <notempty name="info.detail.remark">
		   <div class="weui_cell banjiDom">
		    <div class="weui_cell_hd"><label class="weui_label">备注</label></div>
		    <div class="weui_cell_bd weui_cell_primary">
		    	 {$info.detail.remark}
		    </div>
		  </div>
		 </notempty>
		<eq name="info['status']" value="2">
		<div style="padding:15px;">
		  	<a href="javascript:;" class="weui_btn weui_btn_primary weixin_pay" data-status="0">支付</a>
		</div>
		</eq>
    </div>
  </div>
</div>
</div>

<div id="msg_popup" class="weui-popup-container popup-bottom">
  <div class="weui-popup-overlay"></div>
  <div class="weui-popup-modal">
  	<div class="content-padded" style="padding: 15px">
  		<p>{:str_to_html($info['xiaoqu']['msg'])}</p>
  		<a href="javascript:;" class="weui_btn weui_btn_primary close-popup">确定</a>
  	</div>
  </div>
</div>
</block>

<block name="script">
<script>

$(function(){
	<if condition="$info['xiaoqu']['msg']">
	$("#msg_popup").popup();
	</if>
})

<eq name="info['status']" value="2">
$(".weixin_pay").on('click',function(){
	var orderid = {$info.id};
	$.post('/Api/Pay/check_number_for_baoming',{orderid:orderid},function(data){
		if(data.status){
			callpay();
		}else{
			$.alert(data.info,'',function(){
				location.reload();
			})
		}
	})
	
})
function jsApiCall(){
	WeixinJSBridge.invoke(
		'getBrandWCPayRequest',
		<?php echo $jsApiParameters; ?>,
		function(res){
			//如果支付成功
			if (res.err_msg == 'get_brand_wcpay_request:ok') {
				$.alert('支付成功', function(){
					location.href='/home/my/index';
		        });
			}else if (res.err_msg == 'get_brand_wcpay_request:cancel') {
				$.alert('请尽快完成支付哦！','');
			}else if (res.err_msg == 'get_brand_wcpay_request:fail') {
				$.alert('支付失败','');
			}else {
				$.alert('意外错误','');
			}
		}
	);
}
function callpay(){
	if (typeof WeixinJSBridge == "undefined"){
	    if( document.addEventListener ){
	        document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
	    }else if (document.attachEvent){
	        document.attachEvent('WeixinJSBridgeReady', jsApiCall); 
	        document.attachEvent('onWeixinJSBridgeReady', jsApiCall);
	    }
	}else{
	    jsApiCall();
	}
}
</eq>
</script>
</block>

